#include "Train.h"

class Solution {
public:
    int takeAttendance(vector<int>& records) {
        int l = 0, r = records.size() - 1;
        while (l < r)
        {
            int mid = (r - l) / 2 + l;
            if (records[mid] == mid) l = mid + 1;
            else r = mid;
        }
        return records[l] == l ? l + 1 : l;
    }
};